#ifndef _ADC_h_
#define _ADC_h_
#include "STC12C5630AD.H"
#include "intrins.h"

#define FOSC    11059200L
#define BAUD    9600


/*Declare SFR associated with the ADC */
//sfr ADC_CONTR   =   0xC5;           //ADC control register
//sfr ADC_DATA    =   0xC6;           //ADC high 8-bit result register
//sfr ADC_LOW2    =   0xBE;           //ADC low 2-bit result register
//sfr P1M0        =   0x91;           //P1 mode control register0
//sfr P1M1        =   0x92;           //P1 mode control register1

/*Define ADC operation const for ADC_CONTR*/
#define ADC_POWER   0x80            //ADC power control bit
#define ADC_FLAG    0x10            //ADC complete flag
#define ADC_START   0x08            //ADC start control bit
#define ADC_SPEEDLL 0x00            //420 clocks
#define ADC_SPEEDL  0x20            //280 clocks
#define ADC_SPEEDH  0x40            //140 clocks
#define ADC_SPEEDHH 0x60            //70 clocks


void InitADC();
unsigned char  GetADCResult(unsigned char ch);
void Delay(unsigned int n);

#endif